﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using Noris.Schedule.Support.Components;
using Noris.Schedule.Support.Core;

namespace Noris.Schedule.Support.Forms
{
	#region CLASS ShowInfo : TŘÍDA PRO OKNO ZOBRAZUJÍCÍ TEXT PLUS DODATKOVÝ TEXT
	/// <summary>
	/// Třída pro zobrazování informací
	/// </summary>
	public class ShowInfo : ShowForm
	{
		#region KONSTRUKCE
		/// <summary>
		/// V této metodě zdejší třída vygeneruje buttony do nadřízeného formu.
		/// </summary>
		protected override void OnButtonPanelFill()
		{
			this.Button1 = new Button();
			this.Button1.Location = new System.Drawing.Point(52, 3);
			this.Button1.Name = "Button1";
			this.Button1.Size = new System.Drawing.Size(100, 29);
			this.Button1.TabIndex = 1;
			this.Button1.Text = "";
			this.Button1.UseVisualStyleBackColor = true;
			this.Button1.Visible = false;
			this.Button1.Click += new System.EventHandler(this.Button_Click);

			this.Button2 = new Button();
			this.Button2.Location = new System.Drawing.Point(158, 3);
			this.Button2.Name = "Button2";
			this.Button2.Size = new System.Drawing.Size(100, 29);
			this.Button2.TabIndex = 2;
			this.Button2.Text = "";
			this.Button2.UseVisualStyleBackColor = true;
			this.Button2.Visible = false;
			this.Button2.Click += new System.EventHandler(this.Button_Click);

			this.Button3 = new Button();
			this.Button3.Location = new System.Drawing.Point(264, 3);
			this.Button3.Name = "Button3";
			this.Button3.Size = new System.Drawing.Size(100, 29);
			this.Button3.TabIndex = 3;
			this.Button3.Text = "";
			this.Button3.UseVisualStyleBackColor = true;
			this.Button3.Visible = false;
			this.Button3.Click += new System.EventHandler(this.Button_Click);

			this.ButtonPanel.Controls.Add(this.Button1);
			this.ButtonPanel.Controls.Add(this.Button2);
			this.ButtonPanel.Controls.Add(this.Button3);

			this.DialogResult = DialogResult.None;
		}
		protected Button Button1;
		protected Button Button2;
		protected Button Button3;
		#endregion
		#region PROPERTY, ŘÍZENÍ MNOŽSTVÍ A TYPU BUTTONŮ, DIALOGRESULT
		/// <summary>
		/// Druhy buttonů
		/// </summary>
		public MessageBoxButtons MessageButtonsType
		{
			get { return this._MessageButtonsType; }
			set { this._MessageButtonsType = value; this._SetButtons(); }
		}
		private MessageBoxButtons _MessageButtonsType;
		/// <summary>
		/// Akceptuje typ buttonů this._MessageButtonsType
		/// </summary>
		private void _SetButtons()
		{
			if (this.InvokeRequired)
			{
				this.BeginInvoke(new Action(_SetButtons));
				return;
			}

			int lastRight = 0;
			this.Button1.Visible = false;
			this.Button2.Visible = false;
			this.Button3.Visible = false;
			switch (this._MessageButtonsType)
			{
				case MessageBoxButtons.OK:
					this._SetButtonsData(this.Button1, "OK", DialogResult.OK);
					lastRight = this.Button1.Right + 3;
					break;
				case MessageBoxButtons.OKCancel:
					this._SetButtonsData(this.Button1, "OK", DialogResult.OK);
					this._SetButtonsData(this.Button2, "Storno", DialogResult.Cancel);
					lastRight = this.Button2.Right + 3;
					break;
				case MessageBoxButtons.AbortRetryIgnore:
					this._SetButtonsData(this.Button1, "Zrušit", DialogResult.Abort);
					this._SetButtonsData(this.Button2, "Znovu", DialogResult.Retry);
					this._SetButtonsData(this.Button3, "Ignorovat", DialogResult.Ignore);
					lastRight = this.Button3.Right + 3;
					break;
				case MessageBoxButtons.YesNoCancel:
					this._SetButtonsData(this.Button1, "Ano", DialogResult.Yes);
					this._SetButtonsData(this.Button2, "Ne", DialogResult.No);
					this._SetButtonsData(this.Button3, "Storno", DialogResult.Cancel);
					lastRight = this.Button3.Right + 3;
					break;
				case MessageBoxButtons.YesNo:
					this._SetButtonsData(this.Button1, "Ano", DialogResult.Yes);
					this._SetButtonsData(this.Button2, "Ne", DialogResult.No);
					lastRight = this.Button2.Right + 3;
					break;
				case MessageBoxButtons.RetryCancel:
					this._SetButtonsData(this.Button1, "Opakovat", DialogResult.Retry);
					this._SetButtonsData(this.Button2, "Zrušit", DialogResult.Cancel);
					lastRight = this.Button2.Right + 3;
					break;
				default:
					this._SetButtonsData(this.Button1, "Zavřít", DialogResult.Cancel);
					lastRight = this.Button1.Right + 3;
					break;
			}

			// Šířka ButtonPanel = Right posledního viditelného buttonu:
			this.ButtonPanel.Width = lastRight;
			this.ResizePanel1();
		}
		/// <summary>
		/// Nastaví vlastnosti jednoho buttonu
		/// </summary>
		/// <param name="button"></param>
		/// <param name="text"></param>
		/// <param name="dialogResult"></param>
		private void _SetButtonsData(Button button, string text, DialogResult dialogResult)
		{
			button.Text = text;
			button.Tag = dialogResult;
			button.Visible = true;
		}
		private void Button_Click(object sender, EventArgs e)
		{
			Control button = sender as Control;
			if (button != null)
				this.DialogResult = (DialogResult)button.Tag;
			this.Close();
		}
		#endregion
	}
	#endregion
	#region CLASS ShowForm : BÁZOVÁ TŘÍDA PRO OKNA TYPU Dialog, ShowInfo / ShowError / GetButton
	/// <summary>
	/// Třída pro zobrazování informací
	/// </summary>
	public abstract class ShowForm : FormC
	{
		#region KONSTRUKCE, RESIZE, PROMĚNNÉ
		public ShowForm()
		{
			this.InitComponent();
			this.OnButtonPanelFill();
			this.InitExpandState();
		}
		protected virtual void ShowForm_Resize(object sender, EventArgs e)
		{
			this.SplitCnt.Bounds = new Rectangle(new Point(0, 0), this.ClientSize);
			this.ResizePanel1();
		}
		protected virtual void SplitCnt_SplitterMoved(object sender, SplitterEventArgs e)
		{
			this.ResizePanel1();
		}
		protected bool ResizePanel1Disable = false;
		protected void ResizePanel1()
		{
			if (ResizePanel1Disable) return;
			Size panel1s = this.SplitCnt.Panel1.ClientSize;

			int leftGrp = 12;
			int rightGrp = 12;

			bool isImage = (this.TextPicture.Image != null);     // Svítí obrázek?
			if (isImage)
			{
				Size imageSize = this.TextPicture.Image.Size;
				this.TextPicture.Bounds = new Rectangle(new Point(12, 18), imageSize);
				leftGrp = this.TextPicture.Bounds.Right + 12;
			}

			int leftButtons = panel1s.Width - this.ButtonPanel.Width - 4;
			int topButtons = panel1s.Height - this.ButtonPanel.Height - 3;
			this.DetailsBtn.Location = new Point(12, topButtons + 3);
			this.ButtonPanel.Location = new Point(leftButtons, topButtons);

			Rectangle boundGrp = new Rectangle(leftGrp, 12, panel1s.Width - leftGrp - rightGrp, this.ButtonPanel.Top - this.TextGrp.Top - 3);
			this.TextGrp.Bounds = boundGrp;
		}
		protected SplitContainer SplitCnt;
		protected PictureBox TextPicture;
		protected GroupBox TextGrp;
		protected Label TextLbl;
		protected RichTextBox TextRtf;
		protected Button DetailsBtn;
		protected Panel ButtonPanel;
		protected Button CopyBtn;
		protected Label DetailLbl;
		protected RichTextBox DetailRtf;
		protected void InitExpandState()
		{
			this.SplitCnt.Panel1MinSize = 120;
			this.Resize += new EventHandler(ShowForm_Resize);
			this.SplitCnt.SplitterMoved += new SplitterEventHandler(SplitCnt_SplitterMoved);
			this.StartPosition = FormStartPosition.CenterParent;
			this.ExpandStateHide();
		}
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
		protected override void Dispose(bool disposing)
		{
			base.Dispose(disposing);
		}
		/// <summary>
		/// Velikost panelu 2 v okamžiku, kdy byl schován (šipka nahoru)
		/// </summary>
		protected int Panel2Height;
		protected int _SplitterDistance;
		#endregion
		#region INICIACE FORMU
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitComponent()
		{
			this.TextPicture = new PictureBox();
			this.TextLbl = new System.Windows.Forms.Label();
			this.TextGrp = new System.Windows.Forms.GroupBox();
			this.TextRtf = new RichTextBox();
			this.DetailsBtn = new System.Windows.Forms.Button();
			this.SplitCnt = new System.Windows.Forms.SplitContainer();
			this.DetailLbl = new Label();
			this.DetailRtf = new System.Windows.Forms.RichTextBox();
			this.ButtonPanel = new System.Windows.Forms.Panel();
			this.CopyBtn = new System.Windows.Forms.Button();
			this.TextGrp.SuspendLayout();
			this.ButtonPanel.SuspendLayout();
			this.SplitCnt.Panel1.SuspendLayout();
			this.SplitCnt.Panel2.SuspendLayout();
			this.SplitCnt.SuspendLayout();
			this.SuspendLayout();
			// 
			// TextPicture
			// 
			this.TextPicture.Location = new System.Drawing.Point(12, 12);
			this.TextPicture.Visible = false;
			// 
			// TextLbl
			// 
			this.TextLbl.Dock = System.Windows.Forms.DockStyle.Fill;
			this.TextLbl.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
			this.TextLbl.ForeColor = System.Drawing.Color.MidnightBlue;
			this.TextLbl.Location = new System.Drawing.Point(3, 16);
			this.TextLbl.Name = "TextLbl";
			this.TextLbl.Size = new System.Drawing.Size(462, 65);
			this.TextLbl.TabIndex = 0;
			this.TextLbl.Text = "Titulek";
			this.TextLbl.Visible = false;
			// 
			// TextRtf
			// 
			this.TextRtf.Dock = DockStyle.Fill;
			this.TextRtf.Name = "TextRtf";
			this.TextRtf.ReadOnly = true;
			this.TextRtf.TabIndex = 2;
			this.TextRtf.Text = "";
			this.TextRtf.WordWrap = false;
			this.TextRtf.Visible = false;
			// 
			// TextGrp
			// 
			this.TextGrp.Controls.Add(this.TextLbl);
			this.TextGrp.Controls.Add(this.TextRtf);
			this.TextGrp.Location = new System.Drawing.Point(12, 12);
			this.TextGrp.Name = "TextGrp";
			this.TextGrp.Size = new System.Drawing.Size(468, 84);
			this.TextGrp.TabIndex = 2;
			this.TextGrp.TabStop = false;
			this.TextGrp.Text = " Zpráva : ";
			// 
			// DetailsBtn
			// 
			this.DetailsBtn.Location = new System.Drawing.Point(6, 3);
			this.DetailsBtn.Name = "DetailsBtn";
			this.DetailsBtn.Size = new System.Drawing.Size(40, 29);
			this.DetailsBtn.TabIndex = 4;
			this.DetailsBtn.UseVisualStyleBackColor = true;
			this.DetailsBtn.Click += new System.EventHandler(this.DetailsBtn_Click);
			// 
			// ButtonPanel
			// 
			this.ButtonPanel.Location = new System.Drawing.Point(114, 102);
			this.ButtonPanel.Name = "ButtonPanel";
			this.ButtonPanel.Size = new System.Drawing.Size(369, 36);
			this.ButtonPanel.TabIndex = 3;
			// 
			// SplitCnt
			// 
			this.SplitCnt.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.SplitCnt.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
			this.SplitCnt.Location = new System.Drawing.Point(0, 0);
			this.SplitCnt.Name = "SplitCnt";
			this.SplitCnt.Orientation = System.Windows.Forms.Orientation.Horizontal;
			// 
			// SplitCnt.Panel1
			// 
			this.SplitCnt.Panel1.Controls.Add(this.TextPicture);
			this.SplitCnt.Panel1.Controls.Add(this.TextGrp);
			this.SplitCnt.Panel1.Controls.Add(this.DetailsBtn);
			this.SplitCnt.Panel1.Controls.Add(this.ButtonPanel);
			this.SplitCnt.Panel1MinSize = 100;
			// 
			// SplitCnt.Panel2
			// 
			this.SplitCnt.Panel2.Controls.Add(this.DetailRtf);
			this.SplitCnt.Panel2.Controls.Add(this.DetailLbl);
			this.SplitCnt.Panel2.Controls.Add(this.CopyBtn);
			this.SplitCnt.Panel2MinSize = 100;
			this.SplitCnt.Size = new System.Drawing.Size(495, 447);
			this.SplitCnt.SplitterDistance = 144;
			this.SplitCnt.TabIndex = 4;
			// 
			// DetailLbl
			// 
			this.DetailLbl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
						| System.Windows.Forms.AnchorStyles.Left)
						| System.Windows.Forms.AnchorStyles.Right)));
			this.DetailLbl.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.0F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
			this.DetailLbl.ForeColor = System.Drawing.Color.Black;
			this.DetailLbl.Location = new System.Drawing.Point(12, 3);
			this.DetailLbl.Name = "DetailLbl";
			this.DetailLbl.Size = new System.Drawing.Size(468, 258);
			this.DetailLbl.TabIndex = 3;
			this.DetailLbl.Text = "Informace";
			this.DetailLbl.Visible = false;

			// 
			// DetailRtf
			// 
			this.DetailRtf.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
						| System.Windows.Forms.AnchorStyles.Left)
						| System.Windows.Forms.AnchorStyles.Right)));
			this.DetailRtf.Location = new System.Drawing.Point(12, 3);
			this.DetailRtf.Name = "DetailRtf";
			this.DetailRtf.ReadOnly = true;
			this.DetailRtf.Size = new System.Drawing.Size(468, 258);
			this.DetailRtf.TabIndex = 2;
			this.DetailRtf.Text = "";
			this.DetailRtf.WordWrap = false;
			this.DetailRtf.Visible = false;
			// 
			// CopyBtn
			// 
			this.CopyBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
			this.CopyBtn.Location = new System.Drawing.Point(378, 267);
			this.CopyBtn.Name = "CopyBtn";
			this.CopyBtn.Size = new System.Drawing.Size(99, 23);
			this.CopyBtn.TabIndex = 0;
			this.CopyBtn.Text = "Do schránky";
			this.CopyBtn.UseVisualStyleBackColor = true;
			this.CopyBtn.Click += new System.EventHandler(this.CopyBtn_Click);
			// 
			// form
			// 
			this.ClientSize = new System.Drawing.Size(495, 447);
			this.Controls.Add(this.SplitCnt);
			this.MinimumSize = new System.Drawing.Size(395, 189);
			this.Name = "ShowForm";
			this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show;
			this.Text = "Informace";
			this.TextGrp.ResumeLayout(false);
			this.ButtonPanel.ResumeLayout(false);
			this.SplitCnt.Panel1.ResumeLayout(false);
			this.SplitCnt.Panel2.ResumeLayout(false);
			this.SplitCnt.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion
		#region ABSTRACT, VIRTUAL, ZOBRAZENÍ TEXTŮ
		/// <summary>
		/// Je třeba naplnit buttony do panelu ButtonPanel.
		/// Tedy: vytvořit buttony, naháčkovat do nich eventy, buttony umístit do this.ButtonPanel, zajistit rozměr ButtonPanel.
		/// Umístění ButtonPanel v parentu neřešíme, to řeší parent.
		/// </summary>
		protected abstract void OnButtonPanelFill();
		/// <summary>
		/// Je třeba změnit stav Expanded a vyvolat vizuální změnu.
		/// base metoda to zajistí.
		/// </summary>
		protected virtual void ToggleExpandState()
		{
			this.IsExpanded = !this.IsExpanded;
			this.SetVisualExpandedState();
		}
		/// <summary>
		/// Přečte texty ze svých property, zformátuje je a vloží do controlů.
		/// Metoda je volaná po každém setování hodnot do property, které nesou text.
		/// Tato metoda nemusí řešit invokaci threadu, je volána v threadu GUI.
		/// </summary>
		protected virtual void ShowTexts()
		{
			this.ShowPicture();
			this.ShowTextOne(this.GetTextMain(), this.TextLbl, this.TextRtf);
			this.ShowTextOne(this.GetTextExtended(), this.DetailLbl, this.DetailRtf);
			this.DetailsBtn.Visible = this.DisplayDetailButton;
		}
		/// <summary>
		/// Zajistí zobrazení obrázku
		/// </summary>
		protected void ShowPicture()
		{
			bool isOld = (this.TextPicture.Image != null);     // Svítí starý obrázek?
			bool isNew = (this.CurrentImage != null);          // Bude nový obrázek?
			if (!isOld && !isNew) return;                      // Nic tu nebylo, nic tu není => nic ani nebudeme dělat.
			bool callResize = (isOld != isNew);                // Resize bude tehdy, když je rozdíl v existenci obrázku
			if (isOld && isNew)
				callResize = (this.TextPicture.Image.Size != this.CurrentImage.Size);  // Resize bude, když jsou oba a mají jinou velikost
			
			// Zobrazíme:
			if (isNew)
			{
				this.TextPicture.Image = this.CurrentImage;
				this.TextPicture.Visible = true;
			}
			else
			{
				this.TextPicture.Image = null;
				this.TextPicture.Visible = false;
			}

			// Resize?
			if (callResize)
				this.ResizePanel1();
		}
		/// <summary>
		/// Zajistí zobrazení daného textu buď v textboxu, nebo v rtf boxu.
		/// Tato metoda není standardně určena k přepisování.
		/// </summary>
		/// <param name="text"></param>
		/// <param name="textBox"></param>
		/// <param name="textRtf"></param>
		protected void ShowTextOne(string text, Label textBox, RichTextBox textRtf)
		{
			if (String.IsNullOrEmpty(text))
			{
				textBox.Text = "";
				textBox.Visible = false;
				textRtf.Rtf = "";
				textRtf.Visible = false;
			}
			else if (Library.RtfCompliant(text))
			{
				textBox.Text = "";
				textBox.Visible = false;
				textRtf.Rtf = text;
				textRtf.Visible = true;
			}
			else
			{
				textBox.Text = text;
				textBox.Visible = true;
				textRtf.Rtf = "";
				textRtf.Visible = false;
			}
		}
		/// <summary>
		/// Metoda vrací text do hlavního rámečku.
		/// Metodu je vhodné přepsat, pokud se používají jiné než bázové property.
		/// </summary>
		/// <returns></returns>
		protected virtual string GetTextMain()
		{
			if (this.Message != null)
				return this.Message;
			else
				return "Nespecifikovaná chyba";
		}
		/// <summary>
		/// Metoda vrací text do rozšiřujícího rámečku
		/// Metodu je vhodné přepsat, pokud se používají jiné než bázové property.
		/// </summary>
		/// <returns></returns>
		protected virtual string GetTextExtended()
		{
			if (!String.IsNullOrEmpty(this.ExtendedText))
				return ExtendedText;
			else
				return String.Empty;
		}
		#endregion
		#region TOGGLE STATE
		protected void DetailsBtn_Click(object sender, EventArgs e)
		{
			this.ToggleExpandState();
		}
		protected virtual void ExpandStateHide()
		{
			if (IsExpanded)
				ToggleExpandState();
		}
		protected virtual void SetVisualExpandedState()
		{
			this.ResizePanel1Disable = true;
			if (!this.IsExpanded)
			{	// Nyní máme na formuláři zhasnout detaily:
				this.Panel2Height = this.SplitCnt.Height - this.SplitCnt.SplitterDistance;    // Velikost panelu 2
				this.SplitCnt.Panel2MinSize = 0;
				this.SplitCnt.Panel2Collapsed = true;
				this.MinimumSize = new Size(this.MinimumSize.Width, 155);
				this.Height = this.Height - this.Panel2Height;
				this.DetailsBtn.Image = PicLibrary22.Arrowdowndouble3_FromFile;
			}
			else
			{	// Nyní máme na formuláři rozsvítit detaily:
				this.Height = this.Height + this.Panel2Height;
				this.SplitCnt.Panel2MinSize = 120;
				this.SplitCnt.SplitterDistance = this.SplitCnt.Height - this.Panel2Height;
				this.SplitCnt.Panel2Collapsed = false;
				this.DetailsBtn.Image = PicLibrary22.Arrowupdouble3_FromFile;
				this.MinimumSize = new Size(this.MinimumSize.Width, 275);
			}
			this.ResizePanel1Disable = false;
			this.ResizePanel1();
		}
		protected bool IsExpanded = true;
		#endregion
		#region PROPERTY
		/// <summary>
		/// Ikona zobrazená v okně
		/// </summary>
		public System.Windows.Forms.MessageBoxIcon MessageIcon
		{
			get { return this._MessageIcon; }
			set { this._MessageIcon = value; this._MessageImage = null; this._ShowInfoIconInvoke(value); }
		}
		private System.Windows.Forms.MessageBoxIcon _MessageIcon;
		/// <summary>
		/// Obrázek zobrazovaný v okně na místě ikonky
		/// </summary>
		public System.Drawing.Image MessageImage
		{
			get { return this._MessageImage; }
			set { this._MessageImage = value; this._MessageIcon = MessageBoxIcon.None; this._ShowInfoImageInvoke(value); }
		}
		private System.Drawing.Image _MessageImage;
		/// <summary>
		/// Titulek v rámečku zprávy
		/// </summary>
		public string MessageTitle
		{
			get { return this.TextGrp.Text; }
			set { this.TextGrp.Text = value; }
		}
		/// <summary>
		/// Text o chybě. Vložením objektu se ve formuláři objeví jeho data.
		/// </summary>
		public MessageInfo Message
		{
			get { return this._Message; }
			set { this._Message = value; this.ShowTextsInvoke(); }
		}
		protected MessageInfo _Message;
		/// <summary>
		/// Rozšiřující data. Vložením textu se ve formuláři objeví.
		/// </summary>
		public string ExtendedText
		{
			get { return this._ExtendedText; }
			set { this._ExtendedText = value; this.ShowTextsInvoke(); }
		}
		protected string _ExtendedText;
        /// <summary>
		/// Zajistí vyvolání metody this.ShowTexts, a v případě potřeby invokaci do GUI threadu.
		/// Pro vlastní zobrazení dat jiných než v bázové třídě je vhodné přepsat metodu this.ShowTexts() (kompletní řízení zobrazení),
		/// anebo jednotlivé metody GetTextMain() a GetTextExtended()
		/// </summary>
		protected void ShowTextsInvoke()
		{
			if (this.InvokeRequired)
				this.BeginInvoke(new Action(this.ShowTexts));
			else
				this.ShowTexts();
		}
		/// <summary>
		/// Stav Expanded okna
		/// </summary>
		public bool ExpandedState
		{
			get { return this.IsExpanded; }
			set
			{
				// Set proběhne jen při změně hodnoty:
				if (this.IsExpanded == value) return;
				this.IsExpanded = value;
				this.SetVisualExpandedState();
			}
		}
		/// <summary>
		/// Obsahuje true, pokud je přítomen rozšiřující text.
		/// </summary>
		public bool ContainExtendedText { get { return !String.IsNullOrEmpty(this._ExtendedText); } }
		/// <summary>
		/// Příznak, zda se má zobrazovat button Detail.
		/// Defaultně = podle přítomnosti ExtendedText textu (= podle hodnoty ContainExtendedText).
		/// Na potomkovi lze přepsat.
		/// </summary>
		public virtual bool DisplayDetailButton { get { return this.ContainExtendedText; } }
		#endregion
		#region IKONKA
		/// <summary>
		/// Na základě enumu naplní Image MessageImage, a invokuje zobrazení.
		/// </summary>
		/// <param name="value"></param>
		private void _ShowInfoIconInvoke(MessageBoxIcon value)
		{
			this.CurrentImage = this._GetBitmapForSysIcon(value);
			this.ShowTextsInvoke();
		}
		/// <summary>
		/// Daný obrázek uloží do this.MessageImage a invokuje zobrazení.
		/// </summary>
		/// <param name="value"></param>
		private void _ShowInfoImageInvoke(Image value)
		{
			this.CurrentImage = value;
			this.ShowTextsInvoke();
		}
		protected Image CurrentImage;
		/// <summary>
		/// Metoda vrátí Bitmapu pro danou ikonu
		/// </summary>
		/// <param name="icon"></param>
		/// <returns></returns>
		private Image _GetBitmapForSysIcon(MessageBoxIcon icon)
		{
			// Ptáte se, proč tu není switch ?
			//  Byl tady, ale odešel. Nechtěl zpracovávat enum MessageBoxIcon.
			// Ptáte se, proč nechtěl?
			//  Protože enum MessageBoxIcon je špinavý. Některé jeho položky mají podle typu Windows navzájem shodnou hodnotu.
			if (icon == MessageBoxIcon.Asterisk)
				return System.Drawing.SystemIcons.Asterisk.ToBitmap();
			if (icon == MessageBoxIcon.Error)
				return System.Drawing.SystemIcons.Error.ToBitmap();
			if (icon == MessageBoxIcon.Exclamation)
				return System.Drawing.SystemIcons.Exclamation.ToBitmap();
			if (icon == MessageBoxIcon.Hand)
				return System.Drawing.SystemIcons.Hand.ToBitmap();
			if (icon == MessageBoxIcon.Information)
				return System.Drawing.SystemIcons.Information.ToBitmap();
			if (icon == MessageBoxIcon.None)
				return null;
			if (icon == MessageBoxIcon.Question)
				return System.Drawing.SystemIcons.Question.ToBitmap();
			if (icon == MessageBoxIcon.Stop)
				return System.Drawing.SystemIcons.Shield.ToBitmap();
			if (icon == MessageBoxIcon.Warning)
				return System.Drawing.SystemIcons.Warning.ToBitmap();
			return null;
		}

		#endregion
		#region BUTTONY A JEJICH OBSLUHA
		/// <summary>
		/// Chybu dej do clipboardu
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		protected void CopyBtn_Click(object sender, EventArgs e)
		{
			Clipboard.SetText(this.DetailRtf.Rtf, TextDataFormat.Rtf);
		}
		#endregion
	}
	#endregion
}
